# app/config.py (或者 src/config.py)
from pydantic import Field
# Pydantic v2+ 推荐 pydantic-settings
from pydantic_settings import BaseSettings, SettingsConfigDict
from typing import Optional

class Settings(BaseSettings):
    model_config = SettingsConfigDict(env_file='.env', extra='ignore') # 告诉 BaseSettings 从 .env 读取

    # General settings
    APP_NAME: str = "My FastAPI App"
    DEBUG: bool = False
    PORT: int = 8000

    # Database settings
    DATABASE_URL: str
    DATABASE_USER: str
    DATABASE_PASSWORD: str

    # COS settings
    COS_SECRET_ID: str
    COS_SECRET_KEY: str
    COS_REGION: str = "ap-guangzhou"
    COS_BUCKET_NAME: str
    COS_APP_ID: Optional[str] = None # Optional because it can be inferred or derived

    # Example of a sensitive field, usually you'd get it from env
    # API_KEY: str = Field(..., env="MY_API_KEY") # 明确指定环境变量名

# Create an instance of settings to be used throughout the app
settings = Settings()
